package com.youyi.yyviewsdklibrary.Dialog.animator;

import android.support.v4.view.animation.FastOutSlowInInterpolator;
import android.util.Log;
import android.view.View;
import android.view.ViewPropertyAnimator;
import com.youyi.yyviewsdklibrary.Dialog.enums.PopupAnimation;

public class TranslateAnimator extends PopupAnimator {
    public float endTranslationX;
    public float endTranslationY;
    public boolean hasInit = false;
    public float startTranslationX;
    public float startTranslationY;

    public TranslateAnimator(View view, int i, PopupAnimation popupAnimation) {
        super(view, i, popupAnimation);
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator
    public void initAnimator() {
        if (!this.hasInit) {
            this.endTranslationX = this.targetView.getTranslationX();
            this.endTranslationY = this.targetView.getTranslationY();
            applyTranslation();
            this.startTranslationX = this.targetView.getTranslationX();
            this.startTranslationY = this.targetView.getTranslationY();
            Log.e("tag", "endTranslationY: " + this.endTranslationY + "  startTranslationY: " + this.startTranslationY + "   duration: " + this.animationDuration);
        }
    }


    private void applyTranslation() {
        int i = this.popupAnimation.ordinal();
        if (i == 1) {
            this.targetView.setTranslationX((float) (-this.targetView.getRight()));
        } else if (i == 2) {
            this.targetView.setTranslationY((float) (-this.targetView.getBottom()));
        } else if (i == 3) {
            this.targetView.setTranslationX((float) (((View) this.targetView.getParent()).getMeasuredWidth() - this.targetView.getLeft()));
        } else if (i == 4) {
            this.targetView.setTranslationY((float) (((View) this.targetView.getParent()).getMeasuredHeight() - this.targetView.getTop()));
        }
    }

    /* JADX WARNING: Removed duplicated region for block: B:12:0x0033  */
    /* JADX WARNING: Removed duplicated region for block: B:14:? A[RETURN, SYNTHETIC] */
    @Override // com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public void animateShow() {
        /*
            r3 = this;
            int[] r0 = com.youyi.yyviewsdklibrary.Dialog.animator.TranslateAnimator.AnonymousClass1.$SwitchMap$com$youyi$yyviewsdklibrary$Dialog$enums$PopupAnimation
            com.youyi.yyviewsdklibrary.Dialog.enums.PopupAnimation r1 = r3.popupAnimation
            int r1 = r1.ordinal()
            r0 = r0[r1]
            r1 = 1
            if (r0 == r1) goto L_0x0025
            r1 = 2
            if (r0 == r1) goto L_0x0018
            r1 = 3
            if (r0 == r1) goto L_0x0025
            r1 = 4
            if (r0 == r1) goto L_0x0018
            r0 = 0
            goto L_0x0031
        L_0x0018:
            android.view.View r0 = r3.targetView
            android.view.ViewPropertyAnimator r0 = r0.animate()
            float r1 = r3.endTranslationY
            android.view.ViewPropertyAnimator r0 = r0.translationY(r1)
            goto L_0x0031
        L_0x0025:
            android.view.View r0 = r3.targetView
            android.view.ViewPropertyAnimator r0 = r0.animate()
            float r1 = r3.endTranslationX
            android.view.ViewPropertyAnimator r0 = r0.translationX(r1)
        L_0x0031:
            if (r0 == 0) goto L_0x004a
            android.support.v4.view.animation.FastOutSlowInInterpolator r1 = new android.support.v4.view.animation.FastOutSlowInInterpolator
            r1.<init>()
            android.view.ViewPropertyAnimator r0 = r0.setInterpolator(r1)
            int r1 = r3.animationDuration
            long r1 = (long) r1
            android.view.ViewPropertyAnimator r0 = r0.setDuration(r1)
            android.view.ViewPropertyAnimator r0 = r0.withLayer()
            r0.start()
        L_0x004a:
            return
        */
        throw new UnsupportedOperationException("Method not decompiled: com.youyi.yyviewsdklibrary.Dialog.animator.TranslateAnimator.animateShow():void");
    }

    @Override // com.youyi.yyviewsdklibrary.Dialog.animator.PopupAnimator
    public void animateDismiss() {
        if (!this.animating) {
            ViewPropertyAnimator viewPropertyAnimator = null;
            int i = this.popupAnimation.ordinal();
            if (i == 1) {
                this.startTranslationX = (float) (-this.targetView.getRight());
                viewPropertyAnimator = this.targetView.animate().translationX(this.startTranslationX);
            } else if (i == 2) {
                this.startTranslationY = (float) (-this.targetView.getBottom());
                viewPropertyAnimator = this.targetView.animate().translationY(this.startTranslationY);
            } else if (i == 3) {
                this.startTranslationX = (float) (((View) this.targetView.getParent()).getMeasuredWidth() - this.targetView.getLeft());
                viewPropertyAnimator = this.targetView.animate().translationX(this.startTranslationX);
            } else if (i == 4) {
                this.startTranslationY = (float) (((View) this.targetView.getParent()).getMeasuredHeight() - this.targetView.getTop());
                viewPropertyAnimator = this.targetView.animate().translationY(this.startTranslationY);
            }
            if (viewPropertyAnimator != null) {
                observerAnimator(viewPropertyAnimator.setInterpolator(new FastOutSlowInInterpolator()).setDuration((long) (((double) this.animationDuration) * 0.8d)).withLayer()).start();
            }
        }
    }
}
